package com.eliza.spring.cloud.eureka.provider.controller

import com.eliza.spring.cloud.eureka.provider.service.OrderService
import com.eliza.spring.cloud.library.pojo.Order
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
import javax.annotation.Resource


@Controller
@RequestMapping("/order")
class OrderController {
    @Resource
    private lateinit var orderService: OrderService



    @ResponseBody
    @GetMapping("/getAll")
    fun getAll(): String {
        // 根据id查询订单并返回
        return "${orderService.getAllOrder()}"
    }
//    eurekaConsumer
    @GetMapping("/{orderId}")
    @ResponseBody

    fun queryOrderAndUserByOrderId(@PathVariable("orderId") orderId: Long): Order? {
        // 根据id查询订单并返回
        //return orderService.queryOrderById(orderId);
        return orderService.queryOrderAndUserByOrderId(orderId)
    }

}